<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div class="card">
  <p id="firstName"></p>
  <p id="lastName"></p>
  <p id="age"></p>
</div>
<script>
  const user = {
    name: '战三',
    birth: '2000-01'
  }
  const showFirstName = () => {
    document.getElementById('firstName').textContent = `姓：${ user.name[0] }`
  }
  const showLastName = () => {
    document.getElementById('lastName').textContent = `姓：${ user.name.slice(1) }`
  }
  const showAge = () => {
    const birthday = new Date(user.birth).getTime()
    const today = new Date().getTime()

    const age = ((today - birthday) / 365 / 24 / 60 / 60 / 1000).toFixed(1)
    document.getElementById('age').textContent = `年龄：${ age }`
  }


  showFirstName()
  showLastName()
  showAge()
</script>
</body>
</html>
